Polygons#
Download this notebook from GitHub (right-click to download).
import hvplot.pandas # noqa
Using hvplot with geopandas is as simple as loading a geopandas dataframe and calling hvplot on it with geo=True.
import geopandas as gpd
countries = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
countries.sample(5)
| pop_est | continent | name | iso_a3 | gdp_md_est | geometry | |
|---|---|---|---|---|---|---|
| 123 | 1.071632e+07 | Europe | Greece | GRC | 209852 | MULTIPOLYGON (((26.29000 35.29999, 26.16500 35... |
| 139 | 1.397715e+09 | Asia | China | CHN | 14342903 | MULTIPOLYGON (((109.47521 18.19770, 108.65521 ... |
| 55 | 2.331072e+07 | Africa | Niger | NER | 12911 | POLYGON ((14.85130 22.86295, 15.09689 21.30852... |
| 77 | 6.855713e+06 | Asia | Lebanon | LBN | 51991 | POLYGON ((35.82110 33.27743, 35.55280 33.26427... |
| 71 | 1.862875e+07 | Africa | Malawi | MWI | 7666 | POLYGON ((32.75938 -9.23060, 33.73972 -9.41715... |
countries.hvplot(geo=True)
Control the color of the elements using the c option.
countries.hvplot.polygons(geo=True, c='pop_est', hover_cols='all')
You can even color by another series, such as population density:
countries.hvplot.polygons(geo=True, c=countries.pop_est/countries.area, clabel='pop density')
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.
Download this notebook from GitHub (right-click to download).